<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
//查询学生请求
$(document).ready(function(){
	var endPage=0;//结束的页数
	var pageNum=1;//当前页数
	var pageSize=2;//每页显示条数
	
	function findStudentInfo(pageNum,pageSize) {
		$.ajax({
			url: "/TotalScore/findtotalscoreVo/"+pageNum+"/"+pageSize,
			type: "get",
			dataType: "json",
			success: function(data) {
				
				var list= data.list;
				console.log(data);
				
				//每次进来先清空
				$("#tr1").siblings().remove();
				//取值
				endPage=data.pages;//结束的页数大小
				$.each(list,function(index,data){
					
					
					$("<tr id=tr"+index+"><td>"+data.id+"</td>"+
							"<td>"+data.studentid+"</td>"+
							"<td>"+data.courseid+"</td>"+
							"<td>"+data.score+"</td></tr>").appendTo($("#findStuTable"));
					
				});
				
				
				
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert("查找失败，找不到该成绩！");
				/* alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus); */
			},
		})
	}
	//分页点击事件
	$("#preButton").click(function(){
		
		
		pageNum==1?1:pageNum--;
		findStudentInfo(pageNum,pageSize);
		
	});
	$("#nextButton").click(function(){
		
		pageNum==endPage?endPage:pageNum++;
		findStudentInfo(pageNum,pageSize);
	});
	//加载
	findStudentInfo(pageNum,pageSize);
	//end
});

</script>
</head>

	<body>
	<center>
	
		<table border="1" id="findStuTable">
			<tr id="tr1">
				<td>编号</td>
				<td>学生编号</td>
				<td>课程编号</td>
				<td>分数</td>
			</tr>
		</table>
		<input type="button" value="上一页" id="preButton"><input type="button" value="下一页" id="nextButton">
		
		
	</center>
	</body>
</html>
